	
// EnumLicensInfo.h : Declaration of the CEnumLicensInfo

#ifndef __ENUMLICENSINFO_H_
#define __ENUMLICENSINFO_H_

#include "resource.h"       // main symbols
#include "importado.h"

/////////////////////////////////////////////////////////////////////////////
// CEnumLicensInfo
class ATL_NO_VTABLE CEnumLicensInfo : 
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<CEnumLicensInfo, &CLSID_EnumLicensInfo>,
	public ISupportErrorInfo,
	public IDispatchImpl<IEnumLicensInfo, &IID_IEnumLicensInfo, &LIBID_EBASDLLLib>
{
public:
	CEnumLicensInfo()
	{
		m_pUnkMarshaler = NULL;

		m_records = NULL;
		m_first = TRUE;
		m_pos = 0;
		m_length = 0;
	}
	virtual ~CEnumLicensInfo()
	{
		if (m_records)
			m_records->Close();
	}

DECLARE_REGISTRY_RESOURCEID(IDR_ENUMLICENSINFO)
DECLARE_NOT_AGGREGATABLE(CEnumLicensInfo)
DECLARE_GET_CONTROLLING_UNKNOWN()

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CEnumLicensInfo)
	COM_INTERFACE_ENTRY(IEnumLicensInfo)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
	COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
END_COM_MAP()

	HRESULT FinalConstruct()
	{
		return CoCreateFreeThreadedMarshaler(
			GetControllingUnknown(), &m_pUnkMarshaler.p);
	}

	void FinalRelease()
	{
		m_pUnkMarshaler.Release();
	}

	CComPtr<IUnknown> m_pUnkMarshaler;

// ISupportsErrorInfo
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

// IEnumLicensInfo
public:
	STDMETHOD(Clone)(/*[out]*/ IEnumeration ** ppEnumeration);
	STDMETHOD(Reset)();
	STDMETHOD(Skip)(/*[in]*/ ULONG cItems);
	STDMETHOD(Next)(/*[out]*/ IUnknown ** ppUnk, /*[out]*/ ULONG * pcFetched);
private:
	_RecordsetPtr m_records;
	bool m_first;
	ULONG m_pos;
	ULONG m_length;
};

#endif //__ENUMLICENSINFO_H_
